package threadimpl;

/**
 * 继承Thread类的方式
 * 覆写run()方法
 */
public class ThreadExtends {

    public static void main(String[] args) {
        MyThread2 mt1 = new MyThread2("线程A");
        MyThread2 mt2 = new MyThread2("线程B");
        mt1.start();
        mt2.start();
    }
}

class MyThread2 extends Thread{
    private String name;

    public MyThread2(String name){
        this.name = name;
    }
    public void run(){
        for(int i=0;i<10;i++){
            System.out.println(name + "运行，i = " + i);
        }
    }
}